#include "stdio.h"
#include "synch.h"
#include "system.h"
#include "pthread.h"
#include "malloc.h"
#include "time.h"
#include <iostream>
#include <string>
using namespace std;

struct examSheet{
			int age;
			int name;
			int temperature;
			int bloodPressure;
			char symptom[20];
			char xrayresult[3][40];
			int exRoomNum;
			int xray;
			int shot;
			int status; //1=first time 2=second time 0=finish
			int xrayroom;
			int patientType; //1=Adult Patient 2=Child Patient
			int doctorid;
};

struct form{
		int name;
		int age;
		int patientType;
		int id;
};

class waitingRoomMoitor {
	public:	
		waitingRoomMoitor();
		int PatientWaitingCount; //number of patient who is waiting for the WRN
		int wrnStatus;			 //1=FREE, 0==BUSY	
		int wrnTask;   			 //1=patient asks a sheet, 0=patient gives a sheet
		int waitingNurseCount;	 //count of patient who is waiting for the nurse
		int nurseWaitingCount;	 //count of nurses who is waiting for the WRN
		int wnbusy;				 //1=FREE, 0=BUSY
		int id;
		int patientType;
		int nurseid;
		List *examSheetQueue;
		void test();
		struct form *form;			//waiting room nurse - patient exchange form
		struct examSheet* sheet;	//nurse - patient exchange sheet
		struct examSheet* nsheet;	//waiting room nurse - nurse exchange sheet
		struct form* newform();	//waiting room nurse create a new form
		struct examSheet* newExamSheet();	//waiting room nurse create a new examsheet
		
};

class examinationRoomMoitor{
	public:
		examinationRoomMoitor();
		int exRoom[6];
		char symptom[6][30];			//exchange syptom between nurse and patient
		int doctorid[6];
		//Lock exRoomLock("exrl");
		//Condition exRoomCondition("exrc");
		
};

class  doctorOfficeMonitor{
	public:
		doctorOfficeMonitor();
		struct examSheet* sheet;
		//int doctorCount;
		int nurseCount;
		int roomNumber;
		int doctorstatus[4];
		//int roomNumberS;		//1:roomNumber is availabe. 0:roomNumber is not available.
};

class cashierCounterMonitor{
      public:
             cashierCounterMonitor();
             bool cashierState;     //if the cashier is FREE, the cashierState is true; otherwise it's false
             int cashierWaitedCount;     //number of patient waiting for paying their medical fee
             Lock* cashierCounterLock;              //lock for the monitor, patients have to wait if the cashier is BUSY
             Condition* cashierCounterCV;          //condition variable for the monitor
};	

class cashierPatientMonitor{
      public:
             cashierPatientMonitor();
             float medicalFee;      //how much the patient owes
             float moneyPatientPay;      //how much the patient pays
             struct examSheet* cashierExamSheet;  //cashier can read the sheet to tell the patient how much they sould pay
             string receipt;  //cashier should give patient a receipt
             Lock* cashierPatientLock;            //lock for the monitor,
             Condition* cashierPatientCV;         //condition variable for the monitor
};


void patient(int which);
void waitingRoomNurse();
void doctor(int which);
void nurse(int which);
void XrayTechnician(int which);
void cashier();
void parent(int which);
void childPatient(int which);

